-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce RouteParametersConfig #3342
base: main
Are you sure you want to change the base?
Conversation
Hey @TheBlueMatt @tnull, A gentle ping! Would love to get your feedback or approach ACK before moving forward with testing and applying a similar approach on the BOLT11 side. Thanks a lot! |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3342 +/- ##
==========================================
- Coverage 89.61% 89.61% -0.01%
==========================================
Files 127 127
Lines 103533 103569 +36
Branches 103533 103569 +36
==========================================
+ Hits 92785 92811 +26
- Misses 8051 8053 +2
- Partials 2697 2705 +8 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall.
However I am not the right person to judge if the PR is what the ldk team is looking for.
For instance the following is confusing me :) but I think this is a discussion to be done inside the issue
They also don't really make sense in a BOLT 11 world if we pass a Bolt11Invoice directly to ChannelManager (which we should do now that lightning depends on lightning-invoice).
BTW Nice git history!
P.S: I left some API idea comment in some commit review, idk if they are useful or not. probably they will remove a lot of map(_ {})
code, but I had to write the code to confirm
@@ -9303,7 +9309,7 @@ where | |||
pub fn pay_for_offer( | |||
&self, offer: &Offer, quantity: Option<u64>, amount_msats: Option<u64>, | |||
payer_note: Option<String>, payment_id: PaymentId, retry_strategy: Retry, | |||
max_total_routing_fee_msat: Option<u64> | |||
manual_routing_params: Option<ManualRoutingParameters> | |||
) -> Result<(), Bolt12SemanticError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK no needed option here but: what do you think about having the function call like pay_for_offer(offer, OfferParams::default())
where OfferParams
is something like that
struct OfferParams {
quantity: Option<u64>,
amount_msats: Option<u64>,
manual_routing_params: Option<ManualRoutingParameters>,
}
I think is a lot of more verbose in this way, but I also this that this will be a lot of cleaner.
Now I do not think this will fit well in this PR maybe can be a followup one, but with this patter, it is possible to hide future updates to offers (e.g: recurrence or market place feature) without breaking too much the code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a great improvement! It will help keep the function signature cleaner while remaining maintainable for future parameter increases.
Maybe we can take this in a follow-up. @TheBlueMatt, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No strong opinions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
High-level design looks right to me.
@@ -9303,7 +9309,7 @@ where | |||
pub fn pay_for_offer( | |||
&self, offer: &Offer, quantity: Option<u64>, amount_msats: Option<u64>, | |||
payer_note: Option<String>, payment_id: PaymentId, retry_strategy: Retry, | |||
max_total_routing_fee_msat: Option<u64> | |||
manual_routing_params: Option<ManualRoutingParameters> | |||
) -> Result<(), Bolt12SemanticError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No strong opinions.
Updated from pr3342.02 to pr3342.03 (diff): Changes:
|
lightning/src/ln/outbound_payment.rs
Outdated
// Deprecated: Retained for backward compatibility. | ||
// If set during read, this field overrides `RouteParameters::max_total_routing_fee_msat` | ||
// instead of `RouteParametersOverride::max_total_routing_fee_msat`. | ||
max_total_routing_fee_msat: Option<u64>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, I really prefer to handle this kind of thing at the serialization layer rather than in our logic. It'll be pretty annoying to break out impl_writeable_tlv_based_enum_upgradable!
here, though....I wonder if we shouldn't try to (yet again) expand the featureset of our enum-deser logic. Lets get this PR ready in every other way and then I can play with it, maybe in a followup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! 🚀 Thanks a lot!
Looks like most of my previous comments went unaddressed? Just checking cause I interpreted your comment as you addressing them. |
7cdb03f
to
63b08a4
Compare
Updated from pr3342.03 to pr3342.04 (diff): Changes: Update Role of RouteParamsOverride:
Cleanups:
|
Hey Matt, I’m really sorry for missing your previous comments – not sure how that slipped through! I've gone through everything now and made sure to address them all in the latest update. Thanks so much for your patience! 🌟 |
Okay, I probably spent a bit too long on it, but #3378 should let us drop the legacy fields in |
With the current architecture, `pay_for_offer` only allows setting `max_total_routing_fee_msat` as a route parameter. However, it doesn't provide users the flexibility to set other important parameters. This commit introduces a new struct, `RouteParametersConfig`, that optionally allows users to set additional routing parameters. In later commits, this struct will be utilized when paying BOLT12 invoices.
When `pay_for_offer` is called, it creates a new `PendingOutboundPayment` entry with relevant values that will be used when the corresponding invoice is received. This update modifies `AwaitingInvoice` to include the entire `RouteParametersConfig` struct instead of just `max_total_routing_fee_msat`. This change ensures all manual routing parameters are available when finding payment routes. Decisions & Reasoning: 1. **Retention of `max_total_routing_fee_msat` in `AwaitingInvoice` & `InvoiceReceived`** This field is retained to ensure downgrade support. 2. **Introduction of `route_params_config` in `InvoiceReceived`:** This was added for the same reason that `max_total_routing_fee_msat` was originally introduced in PR lightningdevkit#2417. The documentation has been updated to reflect this, based on [this comment](lightningdevkit@d7e2ff6#r1334619765).
This update allows users to call `pay_for_offer` with a set of parameters they wish to manually set for routing the corresponding invoice. By accepting `RouteParametersOverride`, users gain greater control over the routing process.
Updated from pr3342.05 to pr3342.06 (diff): Changes:
|
Lets get a review pass or two on #3378 and see if we want to move forward with it. If we do, we should rebase this on that and do the conversion in |
Partially addresses #3262